#!/usr/bin/python
# vim:ts=4:sw=4:softtabstop=4:smarttab:expandtab
# 
#    Copyright (C) 2007  Keith Dart <keith@dartworks.biz>
#
#    This library is free software; you can redistribute it and/or
#    modify it under the terms of the GNU Lesser General Public
#    License as published by the Free Software Foundation; either
#    version 2.1 of the License, or (at your option) any later version.
#
#    This library is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
#    Lesser General Public License for more details.

"""
Pycopia documentation server.

"""

from pycopia.WWW import framework
from pycopia.WWW import XHTML

from pycopia.aid import partial



def doc_constructor(request, **kwargs):
    doc = XHTML.new_document()
    for name, val in kwargs.items():
        setattr(doc, name, val)
    container = doc.add_section("container")
    header = container.add_section("container", id="header")
    wrapper = container.add_section("container", id="wrapper")
    content = wrapper.add_section("container", id="content")
    navigation = container.add_section("container", id="navigation")
    extra = container.add_section("container", id="extra")
    footer = container.add_section("container", id="footer")
    doc.header = header
    doc.content = content
    doc.nav = navigation
    doc.extra = extra
    doc.footer = footer
    return doc


def main(request):
    resp = framework.ResponseDocument(request, doc_constructor, 
                title="Pycopia Documentation", 
                stylesheet=request.get_url("css", name="default.css"))
    resp.doc.header.add_header(1, "Pycopia Documentation")
#    resp.doc.nav.append(resp.anchor2(front, "Front Matter"))
    return resp.finalize()

def section(request, name):
    resp = framework.ResponseDocument(request, doc_constructor, 
                title="Pycopia %s Documentation" % name, 
                stylesheet=request.get_url("css", name="default.css"))
#    resp.doc.nav.append(resp.anchor2(front, "Front Matter"))
    return resp.finalize()

